<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - id:000977,sync:fuzzer2,src:001052.lcov_info_final - test/gmock-1.7.0/gtest/src/gtest-filepath.cc</title>
  <link rel="stylesheet" type="text/css" href="../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../index.html">top level</a> - <a href="index.html">test/gmock-1.7.0/gtest/src</a> - gtest-filepath.cc<span style="font-size: 80%;"> (source / <a href="gtest-filepath.cc.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">id:000977,sync:fuzzer2,src:001052.lcov_info_final</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">92</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2016-03-13 10:42:47</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">18</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr><td><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : // Copyright 2008, Google Inc.</a>
<span class="lineNum">       2 </span>            : // All rights reserved.
<span class="lineNum">       3 </span>            : //
<span class="lineNum">       4 </span>            : // Redistribution and use in source and binary forms, with or without
<span class="lineNum">       5 </span>            : // modification, are permitted provided that the following conditions are
<span class="lineNum">       6 </span>            : // met:
<span class="lineNum">       7 </span>            : //
<span class="lineNum">       8 </span>            : //     * Redistributions of source code must retain the above copyright
<span class="lineNum">       9 </span>            : // notice, this list of conditions and the following disclaimer.
<span class="lineNum">      10 </span>            : //     * Redistributions in binary form must reproduce the above
<span class="lineNum">      11 </span>            : // copyright notice, this list of conditions and the following disclaimer
<span class="lineNum">      12 </span>            : // in the documentation and/or other materials provided with the
<span class="lineNum">      13 </span>            : // distribution.
<span class="lineNum">      14 </span>            : //     * Neither the name of Google Inc. nor the names of its
<span class="lineNum">      15 </span>            : // contributors may be used to endorse or promote products derived from
<span class="lineNum">      16 </span>            : // this software without specific prior written permission.
<span class="lineNum">      17 </span>            : //
<span class="lineNum">      18 </span>            : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
<span class="lineNum">      19 </span>            : // &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
<span class="lineNum">      20 </span>            : // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
<span class="lineNum">      21 </span>            : // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
<span class="lineNum">      22 </span>            : // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
<span class="lineNum">      23 </span>            : // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
<span class="lineNum">      24 </span>            : // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
<span class="lineNum">      25 </span>            : // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
<span class="lineNum">      26 </span>            : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<span class="lineNum">      27 </span>            : // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<span class="lineNum">      28 </span>            : // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<span class="lineNum">      29 </span>            : //
<span class="lineNum">      30 </span>            : // Authors: keith.ray@gmail.com (Keith Ray)
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            : #include &quot;gtest/gtest-message.h&quot;
<span class="lineNum">      33 </span>            : #include &quot;gtest/internal/gtest-filepath.h&quot;
<span class="lineNum">      34 </span>            : #include &quot;gtest/internal/gtest-port.h&quot;
<span class="lineNum">      35 </span>            : 
<span class="lineNum">      36 </span>            : #include &lt;stdlib.h&gt;
<span class="lineNum">      37 </span>            : 
<span class="lineNum">      38 </span>            : #if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">      39 </span>            : # include &lt;windows.h&gt;
<span class="lineNum">      40 </span>            : #elif GTEST_OS_WINDOWS
<span class="lineNum">      41 </span>            : # include &lt;direct.h&gt;
<span class="lineNum">      42 </span>            : # include &lt;io.h&gt;
<span class="lineNum">      43 </span>            : #elif GTEST_OS_SYMBIAN
<span class="lineNum">      44 </span>            : // Symbian OpenC has PATH_MAX in sys/syslimits.h
<span class="lineNum">      45 </span>            : # include &lt;sys/syslimits.h&gt;
<span class="lineNum">      46 </span>            : #else
<span class="lineNum">      47 </span>            : # include &lt;limits.h&gt;
<span class="lineNum">      48 </span>            : # include &lt;climits&gt;  // Some Linux distributions define PATH_MAX here.
<span class="lineNum">      49 </span>            : #endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">      50 </span>            : 
<span class="lineNum">      51 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">      52 </span>            : # define GTEST_PATH_MAX_ _MAX_PATH
<span class="lineNum">      53 </span>            : #elif defined(PATH_MAX)
<span class="lineNum">      54 </span>            : # define GTEST_PATH_MAX_ PATH_MAX
<span class="lineNum">      55 </span>            : #elif defined(_XOPEN_PATH_MAX)
<span class="lineNum">      56 </span>            : # define GTEST_PATH_MAX_ _XOPEN_PATH_MAX
<span class="lineNum">      57 </span>            : #else
<span class="lineNum">      58 </span>            : # define GTEST_PATH_MAX_ _POSIX_PATH_MAX
<span class="lineNum">      59 </span>            : #endif  // GTEST_OS_WINDOWS
<span class="lineNum">      60 </span>            : 
<span class="lineNum">      61 </span>            : #include &quot;gtest/internal/gtest-string.h&quot;
<span class="lineNum">      62 </span>            : 
<span class="lineNum">      63 </span>            : namespace testing {
<span class="lineNum">      64 </span>            : namespace internal {
<span class="lineNum">      65 </span>            : 
<span class="lineNum">      66 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">      67 </span>            : // On Windows, '\\' is the standard path separator, but many tools and the
<span class="lineNum">      68 </span>            : // Windows API also accept '/' as an alternate path separator. Unless otherwise
<span class="lineNum">      69 </span>            : // noted, a file path can contain either kind of path separators, or a mixture
<span class="lineNum">      70 </span>            : // of them.
<span class="lineNum">      71 </span>            : const char kPathSeparator = '\\';
<span class="lineNum">      72 </span>            : const char kAlternatePathSeparator = '/';
<span class="lineNum">      73 </span>            : const char kPathSeparatorString[] = &quot;\\&quot;;
<span class="lineNum">      74 </span>            : const char kAlternatePathSeparatorString[] = &quot;/&quot;;
<span class="lineNum">      75 </span>            : # if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">      76 </span>            : // Windows CE doesn't have a current directory. You should not use
<span class="lineNum">      77 </span>            : // the current directory in tests on Windows CE, but this at least
<span class="lineNum">      78 </span>            : // provides a reasonable fallback.
<span class="lineNum">      79 </span>            : const char kCurrentDirectoryString[] = &quot;\\&quot;;
<span class="lineNum">      80 </span>            : // Windows CE doesn't define INVALID_FILE_ATTRIBUTES
<span class="lineNum">      81 </span>            : const DWORD kInvalidFileAttributes = 0xffffffff;
<span class="lineNum">      82 </span>            : # else
<span class="lineNum">      83 </span>            : const char kCurrentDirectoryString[] = &quot;.\\&quot;;
<span class="lineNum">      84 </span>            : # endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">      85 </span>            : #else
<span class="lineNum">      86 </span>            : const char kPathSeparator = '/';
<span class="lineNum">      87 </span>            : const char kPathSeparatorString[] = &quot;/&quot;;
<span class="lineNum">      88 </span>            : const char kCurrentDirectoryString[] = &quot;./&quot;;
<span class="lineNum">      89 </span>            : #endif  // GTEST_OS_WINDOWS
<a name="90"><span class="lineNum">      90 </span>            : </a>
<span class="lineNum">      91 </span>            : // Returns whether the given character is a valid path separator.
<span class="lineNum">      92 </span><span class="lineNoCov">          0 : static bool IsPathSeparator(char c) {</span>
<span class="lineNum">      93 </span>            : #if GTEST_HAS_ALT_PATH_SEP_
<span class="lineNum">      94 </span>            :   return (c == kPathSeparator) || (c == kAlternatePathSeparator);
<span class="lineNum">      95 </span>            : #else
<span class="lineNum">      96 </span><span class="lineNoCov">          0 :   return c == kPathSeparator;</span>
<span class="lineNum">      97 </span>            : #endif
<span class="lineNum">      98 </span>            : }
<a name="99"><span class="lineNum">      99 </span>            : </a>
<span class="lineNum">     100 </span>            : // Returns the current working directory, or &quot;&quot; if unsuccessful.
<span class="lineNum">     101 </span><span class="lineNoCov">          0 : FilePath FilePath::GetCurrentDir() {</span>
<span class="lineNum">     102 </span>            : #if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     103 </span>            :   // Windows CE doesn't have a current directory, so we just return
<span class="lineNum">     104 </span>            :   // something reasonable.
<span class="lineNum">     105 </span>            :   return FilePath(kCurrentDirectoryString);
<span class="lineNum">     106 </span>            : #elif GTEST_OS_WINDOWS
<span class="lineNum">     107 </span>            :   char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
<span class="lineNum">     108 </span>            :   return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? &quot;&quot; : cwd);
<span class="lineNum">     109 </span>            : #else
<span class="lineNum">     110 </span><span class="lineNoCov">          0 :   char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };</span>
<span class="lineNum">     111 </span><span class="lineNoCov">          0 :   return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? &quot;&quot; : cwd);</span>
<span class="lineNum">     112 </span>            : #endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     113 </span>            : }
<span class="lineNum">     114 </span>            : 
<span class="lineNum">     115 </span>            : // Returns a copy of the FilePath with the case-insensitive extension removed.
<span class="lineNum">     116 </span>            : // Example: FilePath(&quot;dir/file.exe&quot;).RemoveExtension(&quot;EXE&quot;) returns
<a name="117"><span class="lineNum">     117 </span>            : // FilePath(&quot;dir/file&quot;). If a case-insensitive extension is not</a>
<span class="lineNum">     118 </span>            : // found, returns a copy of the original FilePath.
<span class="lineNum">     119 </span><span class="lineNoCov">          0 : FilePath FilePath::RemoveExtension(const char* extension) const {</span>
<span class="lineNum">     120 </span><span class="lineNoCov">          0 :   const std::string dot_extension = std::string(&quot;.&quot;) + extension;</span>
<span class="lineNum">     121 </span><span class="lineNoCov">          0 :   if (String::EndsWithCaseInsensitive(pathname_, dot_extension)) {</span>
<span class="lineNum">     122 </span><span class="lineNoCov">          0 :     return FilePath(pathname_.substr(</span>
<span class="lineNum">     123 </span><span class="lineNoCov">          0 :         0, pathname_.length() - dot_extension.length()));</span>
<span class="lineNum">     124 </span>            :   }
<span class="lineNum">     125 </span><span class="lineNoCov">          0 :   return *this;</span>
<span class="lineNum">     126 </span>            : }
<span class="lineNum">     127 </span>            : 
<span class="lineNum">     128 </span>            : // Returns a pointer to the last occurence of a valid path separator in
<a name="129"><span class="lineNum">     129 </span>            : // the FilePath. On Windows, for example, both '/' and '\' are valid path</a>
<span class="lineNum">     130 </span>            : // separators. Returns NULL if no path separator was found.
<span class="lineNum">     131 </span><span class="lineNoCov">          0 : const char* FilePath::FindLastPathSeparator() const {</span>
<span class="lineNum">     132 </span><span class="lineNoCov">          0 :   const char* const last_sep = strrchr(c_str(), kPathSeparator);</span>
<span class="lineNum">     133 </span>            : #if GTEST_HAS_ALT_PATH_SEP_
<span class="lineNum">     134 </span>            :   const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator);
<span class="lineNum">     135 </span>            :   // Comparing two pointers of which only one is NULL is undefined.
<span class="lineNum">     136 </span>            :   if (last_alt_sep != NULL &amp;&amp;
<span class="lineNum">     137 </span>            :       (last_sep == NULL || last_alt_sep &gt; last_sep)) {
<span class="lineNum">     138 </span>            :     return last_alt_sep;
<span class="lineNum">     139 </span>            :   }
<span class="lineNum">     140 </span>            : #endif
<span class="lineNum">     141 </span><span class="lineNoCov">          0 :   return last_sep;</span>
<span class="lineNum">     142 </span>            : }
<span class="lineNum">     143 </span>            : 
<span class="lineNum">     144 </span>            : // Returns a copy of the FilePath with the directory part removed.
<span class="lineNum">     145 </span>            : // Example: FilePath(&quot;path/to/file&quot;).RemoveDirectoryName() returns
<span class="lineNum">     146 </span>            : // FilePath(&quot;file&quot;). If there is no directory part (&quot;just_a_file&quot;), it returns
<span class="lineNum">     147 </span>            : // the FilePath unmodified. If there is no file part (&quot;just_a_dir/&quot;) it
<a name="148"><span class="lineNum">     148 </span>            : // returns an empty FilePath (&quot;&quot;).</a>
<span class="lineNum">     149 </span>            : // On Windows platform, '\' is the path separator, otherwise it is '/'.
<span class="lineNum">     150 </span><span class="lineNoCov">          0 : FilePath FilePath::RemoveDirectoryName() const {</span>
<span class="lineNum">     151 </span><span class="lineNoCov">          0 :   const char* const last_sep = FindLastPathSeparator();</span>
<span class="lineNum">     152 </span><span class="lineNoCov">          0 :   return last_sep ? FilePath(last_sep + 1) : *this;</span>
<span class="lineNum">     153 </span>            : }
<span class="lineNum">     154 </span>            : 
<span class="lineNum">     155 </span>            : // RemoveFileName returns the directory path with the filename removed.
<span class="lineNum">     156 </span>            : // Example: FilePath(&quot;path/to/file&quot;).RemoveFileName() returns &quot;path/to/&quot;.
<span class="lineNum">     157 </span>            : // If the FilePath is &quot;a_file&quot; or &quot;/a_file&quot;, RemoveFileName returns
<span class="lineNum">     158 </span>            : // FilePath(&quot;./&quot;) or, on Windows, FilePath(&quot;.\\&quot;). If the filepath does
<a name="159"><span class="lineNum">     159 </span>            : // not have a file, like &quot;just/a/dir/&quot;, it returns the FilePath unmodified.</a>
<span class="lineNum">     160 </span>            : // On Windows platform, '\' is the path separator, otherwise it is '/'.
<span class="lineNum">     161 </span><span class="lineNoCov">          0 : FilePath FilePath::RemoveFileName() const {</span>
<span class="lineNum">     162 </span><span class="lineNoCov">          0 :   const char* const last_sep = FindLastPathSeparator();</span>
<span class="lineNum">     163 </span><span class="lineNoCov">          0 :   std::string dir;</span>
<span class="lineNum">     164 </span><span class="lineNoCov">          0 :   if (last_sep) {</span>
<span class="lineNum">     165 </span><span class="lineNoCov">          0 :     dir = std::string(c_str(), last_sep + 1 - c_str());</span>
<span class="lineNum">     166 </span>            :   } else {
<span class="lineNum">     167 </span><span class="lineNoCov">          0 :     dir = kCurrentDirectoryString;</span>
<span class="lineNum">     168 </span>            :   }
<span class="lineNum">     169 </span><span class="lineNoCov">          0 :   return FilePath(dir);</span>
<span class="lineNum">     170 </span>            : }
<span class="lineNum">     171 </span>            : 
<span class="lineNum">     172 </span>            : // Helper functions for naming files in a directory for xml output.
<span class="lineNum">     173 </span>            : 
<span class="lineNum">     174 </span>            : // Given directory = &quot;dir&quot;, base_name = &quot;test&quot;, number = 0,
<span class="lineNum">     175 </span>            : // extension = &quot;xml&quot;, returns &quot;dir/test.xml&quot;. If number is greater
<a name="176"><span class="lineNum">     176 </span>            : // than zero (e.g., 12), returns &quot;dir/test_12.xml&quot;.</a>
<span class="lineNum">     177 </span>            : // On Windows platform, uses \ as the separator rather than /.
<span class="lineNum">     178 </span><span class="lineNoCov">          0 : FilePath FilePath::MakeFileName(const FilePath&amp; directory,</span>
<span class="lineNum">     179 </span>            :                                 const FilePath&amp; base_name,
<span class="lineNum">     180 </span>            :                                 int number,
<span class="lineNum">     181 </span>            :                                 const char* extension) {
<span class="lineNum">     182 </span><span class="lineNoCov">          0 :   std::string file;</span>
<span class="lineNum">     183 </span><span class="lineNoCov">          0 :   if (number == 0) {</span>
<span class="lineNum">     184 </span><span class="lineNoCov">          0 :     file = base_name.string() + &quot;.&quot; + extension;</span>
<span class="lineNum">     185 </span>            :   } else {
<span class="lineNum">     186 </span><span class="lineNoCov">          0 :     file = base_name.string() + &quot;_&quot; + StreamableToString(number)</span>
<span class="lineNum">     187 </span><span class="lineNoCov">          0 :         + &quot;.&quot; + extension;</span>
<span class="lineNum">     188 </span>            :   }
<span class="lineNum">     189 </span><span class="lineNoCov">          0 :   return ConcatPaths(directory, FilePath(file));</span>
<span class="lineNum">     190 </span>            : }
<span class="lineNum">     191 </span>            : 
<a name="192"><span class="lineNum">     192 </span>            : // Given directory = &quot;dir&quot;, relative_path = &quot;test.xml&quot;, returns &quot;dir/test.xml&quot;.</a>
<span class="lineNum">     193 </span>            : // On Windows, uses \ as the separator rather than /.
<span class="lineNum">     194 </span><span class="lineNoCov">          0 : FilePath FilePath::ConcatPaths(const FilePath&amp; directory,</span>
<span class="lineNum">     195 </span>            :                                const FilePath&amp; relative_path) {
<span class="lineNum">     196 </span><span class="lineNoCov">          0 :   if (directory.IsEmpty())</span>
<span class="lineNum">     197 </span><span class="lineNoCov">          0 :     return relative_path;</span>
<span class="lineNum">     198 </span><span class="lineNoCov">          0 :   const FilePath dir(directory.RemoveTrailingPathSeparator());</span>
<span class="lineNum">     199 </span><span class="lineNoCov">          0 :   return FilePath(dir.string() + kPathSeparator + relative_path.string());</span>
<span class="lineNum">     200 </span>            : }
<span class="lineNum">     201 </span>            : 
<a name="202"><span class="lineNum">     202 </span>            : // Returns true if pathname describes something findable in the file-system,</a>
<span class="lineNum">     203 </span>            : // either a file, directory, or whatever.
<span class="lineNum">     204 </span><span class="lineNoCov">          0 : bool FilePath::FileOrDirectoryExists() const {</span>
<span class="lineNum">     205 </span>            : #if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     206 </span>            :   LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str());
<span class="lineNum">     207 </span>            :   const DWORD attributes = GetFileAttributes(unicode);
<span class="lineNum">     208 </span>            :   delete [] unicode;
<span class="lineNum">     209 </span>            :   return attributes != kInvalidFileAttributes;
<span class="lineNum">     210 </span>            : #else
<span class="lineNum">     211 </span>            :   posix::StatStruct file_stat;
<span class="lineNum">     212 </span><span class="lineNoCov">          0 :   return posix::Stat(pathname_.c_str(), &amp;file_stat) == 0;</span>
<span class="lineNum">     213 </span>            : #endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     214 </span>            : }
<span class="lineNum">     215 </span>            : 
<a name="216"><span class="lineNum">     216 </span>            : // Returns true if pathname describes a directory in the file-system</a>
<span class="lineNum">     217 </span>            : // that exists.
<span class="lineNum">     218 </span><span class="lineNoCov">          0 : bool FilePath::DirectoryExists() const {</span>
<span class="lineNum">     219 </span><span class="lineNoCov">          0 :   bool result = false;</span>
<span class="lineNum">     220 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">     221 </span>            :   // Don't strip off trailing separator if path is a root directory on
<span class="lineNum">     222 </span>            :   // Windows (like &quot;C:\\&quot;).
<span class="lineNum">     223 </span>            :   const FilePath&amp; path(IsRootDirectory() ? *this :
<span class="lineNum">     224 </span>            :                                            RemoveTrailingPathSeparator());
<span class="lineNum">     225 </span>            : #else
<span class="lineNum">     226 </span><span class="lineNoCov">          0 :   const FilePath&amp; path(*this);</span>
<span class="lineNum">     227 </span>            : #endif
<span class="lineNum">     228 </span>            : 
<span class="lineNum">     229 </span>            : #if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     230 </span>            :   LPCWSTR unicode = String::AnsiToUtf16(path.c_str());
<span class="lineNum">     231 </span>            :   const DWORD attributes = GetFileAttributes(unicode);
<span class="lineNum">     232 </span>            :   delete [] unicode;
<span class="lineNum">     233 </span>            :   if ((attributes != kInvalidFileAttributes) &amp;&amp;
<span class="lineNum">     234 </span>            :       (attributes &amp; FILE_ATTRIBUTE_DIRECTORY)) {
<span class="lineNum">     235 </span>            :     result = true;
<span class="lineNum">     236 </span>            :   }
<span class="lineNum">     237 </span>            : #else
<span class="lineNum">     238 </span>            :   posix::StatStruct file_stat;
<span class="lineNum">     239 </span><span class="lineNoCov">          0 :   result = posix::Stat(path.c_str(), &amp;file_stat) == 0 &amp;&amp;</span>
<span class="lineNum">     240 </span><span class="lineNoCov">          0 :       posix::IsDir(file_stat);</span>
<span class="lineNum">     241 </span>            : #endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     242 </span>            : 
<span class="lineNum">     243 </span><span class="lineNoCov">          0 :   return result;</span>
<span class="lineNum">     244 </span>            : }
<span class="lineNum">     245 </span>            : 
<a name="246"><span class="lineNum">     246 </span>            : // Returns true if pathname describes a root directory. (Windows has one</a>
<span class="lineNum">     247 </span>            : // root directory per disk drive.)
<span class="lineNum">     248 </span><span class="lineNoCov">          0 : bool FilePath::IsRootDirectory() const {</span>
<span class="lineNum">     249 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">     250 </span>            :   // TODO(wan@google.com): on Windows a network share like
<span class="lineNum">     251 </span>            :   // \\server\share can be a root directory, although it cannot be the
<span class="lineNum">     252 </span>            :   // current directory.  Handle this properly.
<span class="lineNum">     253 </span>            :   return pathname_.length() == 3 &amp;&amp; IsAbsolutePath();
<span class="lineNum">     254 </span>            : #else
<span class="lineNum">     255 </span><span class="lineNoCov">          0 :   return pathname_.length() == 1 &amp;&amp; IsPathSeparator(pathname_.c_str()[0]);</span>
<span class="lineNum">     256 </span>            : #endif
<span class="lineNum">     257 </span>            : }
<a name="258"><span class="lineNum">     258 </span>            : </a>
<span class="lineNum">     259 </span>            : // Returns true if pathname describes an absolute path.
<span class="lineNum">     260 </span><span class="lineNoCov">          0 : bool FilePath::IsAbsolutePath() const {</span>
<span class="lineNum">     261 </span><span class="lineNoCov">          0 :   const char* const name = pathname_.c_str();</span>
<span class="lineNum">     262 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">     263 </span>            :   return pathname_.length() &gt;= 3 &amp;&amp;
<span class="lineNum">     264 </span>            :      ((name[0] &gt;= 'a' &amp;&amp; name[0] &lt;= 'z') ||
<span class="lineNum">     265 </span>            :       (name[0] &gt;= 'A' &amp;&amp; name[0] &lt;= 'Z')) &amp;&amp;
<span class="lineNum">     266 </span>            :      name[1] == ':' &amp;&amp;
<span class="lineNum">     267 </span>            :      IsPathSeparator(name[2]);
<span class="lineNum">     268 </span>            : #else
<span class="lineNum">     269 </span><span class="lineNoCov">          0 :   return IsPathSeparator(name[0]);</span>
<span class="lineNum">     270 </span>            : #endif
<span class="lineNum">     271 </span>            : }
<span class="lineNum">     272 </span>            : 
<span class="lineNum">     273 </span>            : // Returns a pathname for a file that does not currently exist. The pathname
<span class="lineNum">     274 </span>            : // will be directory/base_name.extension or
<span class="lineNum">     275 </span>            : // directory/base_name_&lt;number&gt;.extension if directory/base_name.extension
<span class="lineNum">     276 </span>            : // already exists. The number will be incremented until a pathname is found
<span class="lineNum">     277 </span>            : // that does not already exist.
<span class="lineNum">     278 </span>            : // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
<a name="279"><span class="lineNum">     279 </span>            : // There could be a race condition if two or more processes are calling this</a>
<span class="lineNum">     280 </span>            : // function at the same time -- they could both pick the same filename.
<span class="lineNum">     281 </span><span class="lineNoCov">          0 : FilePath FilePath::GenerateUniqueFileName(const FilePath&amp; directory,</span>
<span class="lineNum">     282 </span>            :                                           const FilePath&amp; base_name,
<span class="lineNum">     283 </span>            :                                           const char* extension) {
<span class="lineNum">     284 </span><span class="lineNoCov">          0 :   FilePath full_pathname;</span>
<span class="lineNum">     285 </span><span class="lineNoCov">          0 :   int number = 0;</span>
<span class="lineNum">     286 </span><span class="lineNoCov">          0 :   do {</span>
<span class="lineNum">     287 </span><span class="lineNoCov">          0 :     full_pathname.Set(MakeFileName(directory, base_name, number++, extension));</span>
<span class="lineNum">     288 </span>            :   } while (full_pathname.FileOrDirectoryExists());
<span class="lineNum">     289 </span><span class="lineNoCov">          0 :   return full_pathname;</span>
<span class="lineNum">     290 </span>            : }
<span class="lineNum">     291 </span>            : 
<span class="lineNum">     292 </span>            : // Returns true if FilePath ends with a path separator, which indicates that
<a name="293"><span class="lineNum">     293 </span>            : // it is intended to represent a directory. Returns false otherwise.</a>
<span class="lineNum">     294 </span>            : // This does NOT check that a directory (or file) actually exists.
<span class="lineNum">     295 </span><span class="lineNoCov">          0 : bool FilePath::IsDirectory() const {</span>
<span class="lineNum">     296 </span><span class="lineNoCov">          0 :   return !pathname_.empty() &amp;&amp;</span>
<span class="lineNum">     297 </span><span class="lineNoCov">          0 :          IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]);</span>
<span class="lineNum">     298 </span>            : }
<span class="lineNum">     299 </span>            : 
<span class="lineNum">     300 </span>            : // Create directories so that path exists. Returns true if successful or if
<a name="301"><span class="lineNum">     301 </span>            : // the directories already exist; returns false if unable to create directories</a>
<span class="lineNum">     302 </span>            : // for any reason.
<span class="lineNum">     303 </span><span class="lineNoCov">          0 : bool FilePath::CreateDirectoriesRecursively() const {</span>
<span class="lineNum">     304 </span><span class="lineNoCov">          0 :   if (!this-&gt;IsDirectory()) {</span>
<span class="lineNum">     305 </span><span class="lineNoCov">          0 :     return false;</span>
<span class="lineNum">     306 </span>            :   }
<span class="lineNum">     307 </span>            : 
<span class="lineNum">     308 </span><span class="lineNoCov">          0 :   if (pathname_.length() == 0 || this-&gt;DirectoryExists()) {</span>
<span class="lineNum">     309 </span><span class="lineNoCov">          0 :     return true;</span>
<span class="lineNum">     310 </span>            :   }
<span class="lineNum">     311 </span>            : 
<span class="lineNum">     312 </span><span class="lineNoCov">          0 :   const FilePath parent(this-&gt;RemoveTrailingPathSeparator().RemoveFileName());</span>
<span class="lineNum">     313 </span><span class="lineNoCov">          0 :   return parent.CreateDirectoriesRecursively() &amp;&amp; this-&gt;CreateFolder();</span>
<span class="lineNum">     314 </span>            : }
<span class="lineNum">     315 </span>            : 
<span class="lineNum">     316 </span>            : // Create the directory so that path exists. Returns true if successful or
<span class="lineNum">     317 </span>            : // if the directory already exists; returns false if unable to create the
<a name="318"><span class="lineNum">     318 </span>            : // directory for any reason, including if the parent directory does not</a>
<span class="lineNum">     319 </span>            : // exist. Not named &quot;CreateDirectory&quot; because that's a macro on Windows.
<span class="lineNum">     320 </span><span class="lineNoCov">          0 : bool FilePath::CreateFolder() const {</span>
<span class="lineNum">     321 </span>            : #if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     322 </span>            :   FilePath removed_sep(this-&gt;RemoveTrailingPathSeparator());
<span class="lineNum">     323 </span>            :   LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());
<span class="lineNum">     324 </span>            :   int result = CreateDirectory(unicode, NULL) ? 0 : -1;
<span class="lineNum">     325 </span>            :   delete [] unicode;
<span class="lineNum">     326 </span>            : #elif GTEST_OS_WINDOWS
<span class="lineNum">     327 </span>            :   int result = _mkdir(pathname_.c_str());
<span class="lineNum">     328 </span>            : #else
<span class="lineNum">     329 </span><span class="lineNoCov">          0 :   int result = mkdir(pathname_.c_str(), 0777);</span>
<span class="lineNum">     330 </span>            : #endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     331 </span>            : 
<span class="lineNum">     332 </span><span class="lineNoCov">          0 :   if (result == -1) {</span>
<span class="lineNum">     333 </span><span class="lineNoCov">          0 :     return this-&gt;DirectoryExists();  // An error is OK if the directory exists.</span>
<span class="lineNum">     334 </span>            :   }
<span class="lineNum">     335 </span><span class="lineNoCov">          0 :   return true;  // No error.</span>
<span class="lineNum">     336 </span>            : }
<span class="lineNum">     337 </span>            : 
<span class="lineNum">     338 </span>            : // If input name has a trailing separator character, remove it and return the
<a name="339"><span class="lineNum">     339 </span>            : // name, otherwise return the name string unmodified.</a>
<span class="lineNum">     340 </span>            : // On Windows platform, uses \ as the separator, other platforms use /.
<span class="lineNum">     341 </span><span class="lineNoCov">          0 : FilePath FilePath::RemoveTrailingPathSeparator() const {</span>
<span class="lineNum">     342 </span><span class="lineNoCov">          0 :   return IsDirectory()</span>
<span class="lineNum">     343 </span><span class="lineNoCov">          0 :       ? FilePath(pathname_.substr(0, pathname_.length() - 1))</span>
<span class="lineNum">     344 </span><span class="lineNoCov">          0 :       : *this;</span>
<span class="lineNum">     345 </span>            : }
<span class="lineNum">     346 </span>            : 
<span class="lineNum">     347 </span>            : // Removes any redundant separators that might be in the pathname.
<span class="lineNum">     348 </span>            : // For example, &quot;bar///foo&quot; becomes &quot;bar/foo&quot;. Does not eliminate other
<a name="349"><span class="lineNum">     349 </span>            : // redundancies that might be in a pathname involving &quot;.&quot; or &quot;..&quot;.</a>
<span class="lineNum">     350 </span>            : // TODO(wan@google.com): handle Windows network shares (e.g. \\server\share).
<span class="lineNum">     351 </span><span class="lineNoCov">          0 : void FilePath::Normalize() {</span>
<span class="lineNum">     352 </span><span class="lineNoCov">          0 :   if (pathname_.c_str() == NULL) {</span>
<span class="lineNum">     353 </span><span class="lineNoCov">          0 :     pathname_ = &quot;&quot;;</span>
<span class="lineNum">     354 </span><span class="lineNoCov">          0 :     return;</span>
<span class="lineNum">     355 </span>            :   }
<span class="lineNum">     356 </span><span class="lineNoCov">          0 :   const char* src = pathname_.c_str();</span>
<span class="lineNum">     357 </span><span class="lineNoCov">          0 :   char* const dest = new char[pathname_.length() + 1];</span>
<span class="lineNum">     358 </span><span class="lineNoCov">          0 :   char* dest_ptr = dest;</span>
<span class="lineNum">     359 </span><span class="lineNoCov">          0 :   memset(dest_ptr, 0, pathname_.length() + 1);</span>
<span class="lineNum">     360 </span>            : 
<span class="lineNum">     361 </span><span class="lineNoCov">          0 :   while (*src != '\0') {</span>
<span class="lineNum">     362 </span><span class="lineNoCov">          0 :     *dest_ptr = *src;</span>
<span class="lineNum">     363 </span><span class="lineNoCov">          0 :     if (!IsPathSeparator(*src)) {</span>
<span class="lineNum">     364 </span><span class="lineNoCov">          0 :       src++;</span>
<span class="lineNum">     365 </span>            :     } else {
<span class="lineNum">     366 </span>            : #if GTEST_HAS_ALT_PATH_SEP_
<span class="lineNum">     367 </span>            :       if (*dest_ptr == kAlternatePathSeparator) {
<span class="lineNum">     368 </span>            :         *dest_ptr = kPathSeparator;
<span class="lineNum">     369 </span>            :       }
<span class="lineNum">     370 </span>            : #endif
<span class="lineNum">     371 </span><span class="lineNoCov">          0 :       while (IsPathSeparator(*src))</span>
<span class="lineNum">     372 </span><span class="lineNoCov">          0 :         src++;</span>
<span class="lineNum">     373 </span>            :     }
<span class="lineNum">     374 </span><span class="lineNoCov">          0 :     dest_ptr++;</span>
<span class="lineNum">     375 </span>            :   }
<span class="lineNum">     376 </span><span class="lineNoCov">          0 :   *dest_ptr = '\0';</span>
<span class="lineNum">     377 </span><span class="lineNoCov">          0 :   pathname_ = dest;</span>
<span class="lineNum">     378 </span><span class="lineNoCov">          0 :   delete[] dest;</span>
<span class="lineNum">     379 </span>            : }
<span class="lineNum">     380 </span>            : 
<span class="lineNum">     381 </span>            : }  // namespace internal
<span class="lineNum">     382 </span>            : }  // namespace testing
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
